<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue 多个元素或组件的过度</title>
    <script charset="UTF-8" src="js/vue.js"></script>
    <!--<script src="js/velocity.js"></script>-->
    <style>
        .fade-enter, .fade-leave-to {
            opacity: 0;
        }

        .fade-enter-active, .fade-leave-active {
            transition: opacity 1s;
        }
    </style>
</head>
<body>
<div id="app">
    <transition name="fade" mode="out-in">
        <!--动态组件-->
        <component :is="type"></component>
        <!--多个组件-->
        <!--<child v-if="show"></child>-->
        <!--<child-one v-else></child-one>-->
        <!--多个元素-->
        <!--<div v-if="show" key="hello">-->
        <!--Hello World-->
        <!--</div>-->
        <!--<div v-else key="bye">-->
        <!--Bye World-->
        <!--</div>-->
    </transition>
    <button @click="handleClick">切换</button>
</div>
<script>
    Vue.component('child', {
        template: '<div>child</div>'
    });
    Vue.component('child-one', {
        template: '<div>child-one</div>'
    });
    let vm = new Vue({
        el: '#app',
        data: {
            // show: true
            type: 'child'
        },
        methods: {
            handleClick: function () {
                // this.show = !this.show;

                this.type = this.type === "child" ? "child-one" : "child"
            }
        }
    });
</script>
</body>
</html>